package com.base.core.idworker;

import java.security.SecureRandom;


/**
 * 随机数算法的工具类.
 *
 * @author biao
 * @version 2019-5-19
 */
public class RandomStrategy implements IdWorkerInterface {

    private static final SecureRandom random = new SecureRandom();


    /**
     * 获取随机数
     */
    public long nextId() {
        long millis = System.currentTimeMillis();
        //加上两位随机数
        int end2 = random.nextInt(99);
        //如果不足两位前面补0
        String str = millis + String.format("%02d", end2);
        long id = new Long(str);
        return id;
    }


}
